<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


class WechatReturnMsgModel 
{
       /**
     * 输出文本消息
     * @param type $object 传入消息
     * @param type $content 回复的消息
     * @param type $flag 是否星标
     */
    public function returnText($object, $content,$micro = 0, $flag = 0){
        $textTpl = "<xml><ToUserName><![CDATA[%s]]></ToUserName>"
                . "<FromUserName><![CDATA[%s]]></FromUserName>"
                . "<CreateTime>%s</CreateTime><MsgType>"
                . "<![CDATA[text]]></MsgType><Content><![CDATA[%s]]></Content>"
                . "</xml>";
        $resultStr = sprintf($textTpl, $object->FromUserName, 
                $object->ToUserName, time(), $content,$flag);
        $test = new \Wechat\Model\TestModel();
        $test->create(array('value'=>"Text||".$resultStr."||".time()."||$micro"));
        $test->add();
        echo $resultStr;
    }
}
